package net.suncaper.hotel.common.utils;

import lombok.Data;
import java.util.List;

/**
 * 分页信息
 */
@Data
public class PageInfo<T> {
    private int pageNum;      // 当前页码
    private int pageSize;     // 每页大小
    private long total;       // 总记录数
    private int pages;        // 总页数
    private List<T> list;     // 数据列表

    public PageInfo() {
        this.pageNum = 1;
        this.pageSize = 10;
    }

    public PageInfo(int pageNum, int pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public void setTotal(long total) {
        this.total = total;
        this.pages = (int) Math.ceil((double) total / pageSize);
    }

    public int getStartRow() {
        return (pageNum - 1) * pageSize;
    }
}